<template>
	<view class="commodity">
		<!-- 单个商品组件 -->
		<view class="commodity-item" v-for="(item,index) in dataList" :key="index" @click="goDetail(item.id)">
			<image class="commodity-img" :src="item.imgUrl" mode=""></image>
			<view class="commodity-content">
				<text class="commodity-name">
					{{item.name}}
				</text>
				<view class="">
					<text class="price_new">￥{{item.price_new}}</text>
					<text class="price_old">￥{{item.price_old}}</text>
				</view>
				<text class="discount">{{item.discount}}折</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			dataList:Array,
		},
		data() {
			return {
				discount: 5
			}
		},
		computed:{
			
		},
		methods: {
			goDetail(id){
				// console.log(123);
				uni.navigateTo({
					url:'../../pages/details/details?id='+id+''
					// url:'@/pages/details/details'
				})
			},
		}
	}
</script>

<style>
.commodity{
	display: flex;
	flex-wrap: wrap;
}
.commodity-item{
	width: 375rpx;
	padding-bottom: 20rpx;
}
.commodity-img{
	width: 100%;
	height: 375rpx;
}
.commodity-content{
	text-align: center;
}
.commodity-name{
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	color: #333333;
	word-break: break-all;
	padding: 3rpx 10rpx;
}
.price_old{
	text-decoration: line-through;
	font-size: 24rpx;
	color: #a7a7a7;
}
.discount{
	border-radius: 4rpx;
	border: 1px solid #616161;
	color: #dd0000;
	padding: 2rpx 10rpx;
	font-size: 20rpx;
	font-weight: bold;
}
</style>
